package com.johnny.xia.util;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.github.stuxuhai.jpinyin.PinyinFormat;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import org.springframework.util.StopWatch;

import java.util.Arrays;

public class JPinyinUtil {
    public static void main(String[] args) throws PinyinException {

        String str = "中国 哈哈 johnny xia 女";

        StopWatch watch = new StopWatch();
        watch.start("jp");
        String res = PinyinHelper.convertToPinyinString(str, "", PinyinFormat.WITHOUT_TONE);
        watch.stop();

        watch.start("py");
        String  res2 = PinYin4jUtils.stringToPinyinString(str,false,null);
        watch.stop();


        System.out.println(watch.prettyPrint());

        System.out.println(res+"-->"+res2);
    }
}
